﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Hanhud.Win.Pages
{
    public partial class frmPages : Form
    {
        public frmPages()
        {
            InitializeComponent();
        }

        private void frmPages_Load(object sender, EventArgs e)
        {

        }

        void GetPageList()
        { 
                                
        }

        private void btnEdit_Click(object sender, EventArgs e)
        {
            try
            {
                if (grdPage.CurrentRow == null) return;
                PageBAL balPage = new PageBAL();
                Page page = balPage.Get(grdPage.CurrentRow.Cells["cModule"].Value.ToString(),
                    grdPage.CurrentRow.Cells["cName"].Value.ToString());
                if (page == null)
                    throw new Exception("Không tìm thấy trang.");

                using (frmPagesEdit f = new frmPagesEdit(page))
                {
                    if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        balPage.Update(page);
                        grdPage.CurrentRow.Cells["cTitle"].Value = page.Title;
                        grdPage.CurrentRow.Cells["cDesciption"].Value = page.Description;
                        grdPage.CurrentRow.Cells["cKeywords"].Value = page.Keywords;                    
                    }
                    
                }

            }
            catch (Exception ex)
            {
                UIFunction.ShowErrMsg(ex.Message);
            }
            
        }
    }
}
